package edu.pku.sei.transformation.qvt.adapter;

import edu.pku.sei.transformation.editor.model.GraphicalDomain;
import edu.pku.sei.transformation.qvt.rule.IDomain;
import edu.pku.sei.transformation.qvt.rule.IObjectTemplate;
import edu.pku.sei.transformation.qvt.rule.IPattern;

public class DomainAdapter implements IDomain {
	protected GraphicalDomain element;
	protected IPattern pattern;
	public DomainAdapter(GraphicalDomain element) {
		this.element = element;
		pattern = new PatternAdapter(element.getPattern());
	}
	@Override
	public IPattern getPattern() {
		return pattern;
	}

	@Override
	public IObjectTemplate getRootElement() {
		if (pattern.getNodes().size() == 0)
			System.err.println("no element in domain");
		return pattern.getNodes().get(0);
	}

	@Override
	public String getTypedModelName() {
		if (element.getTypedModel() == null)
			return "";
		else
			return element.getTypedModel().getName();
	}

	@Override
	public boolean isEnforce() {
		return element.isEnforceable();
	}

}
